﻿//// Copyright (c) Yoganand R. All rights reserved.
//// For continued development and updates, visit http://yogsbreath.net
//using System;
//using System.Collections.Generic;
//using System.Web.UI.WebControls;
//using System.ComponentModel;
//using System.IO;
//using System.Reflection;
//using System.Collections;
//using System.Web.UI;
//using System.Text;

//namespace MVCnExt.Web.UI.Ext
//{
//    /// <summary>
//    /// Adds the ability for single level grouping to the grid.
//    /// </summary>
//    [Description("Adds the ability for single level grouping to the grid.")]
//    public class ExtGroupingGrid : ExtComponent 
//    {
//        public override List<ScriptReference> GetScriptReferences()
//        {
//            return base.GetScriptReferences();
//        }

//        public override IList<ScriptDescriptor> GetScriptDescriptors()
//        {
//            IList<ScriptDescriptor> list = base.GetScriptDescriptors();

//            ScriptControlDescriptorBase desc = (ScriptControlDescriptorBase)list[0];

//            desc.Type = "Ext.form.Checkbox";

//            String[] properties = new String[]{
//                "boxLabel", "checked", "fieldLabel", "name"       
//            };

//            Type component = typeof(ExtPanel);

//            foreach (String property in properties)
//            {
//                PropertyInfo i = component.GetProperty(property);

//                if (i == null)
//                    throw new InvalidOperationException(String.Format("Property not found, 'ExtJsPanel.{0}'", property));

//                Object value = i.GetValue(this, null);

//                if (value == null)
//                {
//                    continue;
//                }

//                if (!(value is String))
//                    desc.AddPropertyBase(property, value);
//                else
//                    desc.AddPropertyBase(property, String.Format("'{0}'", value));
//            }

//            return list;
//        }

//        #region Public Properties

//        /// <summary>
//        /// The text to display when there is an empty group value.
//        /// </summary>
//        [Description("The text to display when there is an empty group value.")]
//        public Boolean emptyGroupText { get; set; }

//        /// <summary>
//        /// False to disable grouping functionality (defaults to true).
//        /// </summary>
//        [DefaultValue(true)]
//        [Description("False to disable grouping functionality (defaults to true).")]
//        public Boolean enableGrouping { get; set; }

//        /// <summary>
//        /// True to enable the grouping control in the column menu.
//        /// </summary>
//        [DefaultValue(true)]
//        [Description("True to enable the grouping control in the column menu.")]
//        public Boolean enableGroupingMenu { get; set; }

//        /// <summary>
//        /// True to allow the user to turn off grouping.
//        /// </summary>
//        [DefaultValue(true)]
//        [Description("True to allow the user to turn off grouping.")]
//        public Boolean enableNoGroups { get; set; }

//        /// <summary>
//        /// Text displayed in the grid header menu for grouping by a column (defaults to 'Group By This Field').
//        /// </summary>       
//        [DefaultValue("Group By This Field")]
//        [Description("Text displayed in the grid header menu for grouping by a column (defaults to 'Group By This Field').")]
//        public String groupByText { get; set; }

//        /// <summary>
//        /// The template used to render the group header. See Ext.XTemplate for information on how to format data using a template.
//        /// </summary>
//        [Description("The template used to render the group header. See Ext.XTemplate for information on how to format data using a template.")]
//        public String groupTextTpl { get; set; }

//        /// <summary>
//        /// The text with which to prefix the group field value in the group header line.
//        /// </summary>  
//        [Description("The text with which to prefix the group field value in the group header line.")]
//        public String header { get; set; }

//        /// <summary>
//        /// True to hide the column that is currently grouped.
//        /// </summary>
//        [Description("True to hide the column that is currently grouped.")]
//        public Boolean? hideGroupedColumn { get; set; }

//        /// <summary>
//        /// True to skip refreshing the view when new rows are added (defaults to false).
//        /// </summary>
//        [Description("True to skip refreshing the view when new rows are added (defaults to false).")]
//        public Boolean? ignoreAdd { get; set; }

//        /// <summary>
//        /// True to display the name for each set of grouped rows (defaults to true).
//        /// </summary>
//        [DefaultValue(true)]
//        [Description("True to display the name for each set of grouped rows (defaults to true).")]
//        public Boolean showGroupName { get; set; }

//        /// <summary>
//        /// Text displayed in the grid header for enabling/disabling grouping (defaults to 'Show in Groups').
//        /// </summary>
//        [DefaultValue("Show in Groups")]
//        [Description("Text displayed in the grid header for enabling/disabling grouping (defaults to 'Show in Groups').")]
//        public String showGroupsText { get; set; }

//        /// <summary>
//        /// True to start all groups collapsed.
//        /// </summary>
//        [Description("True to start all groups collapsed.")]
//        public Boolean? startCollapsed { get; set; }

//        #endregion
//    }
//}
